<template>
	<view>
		<!-- 商品信息-->
		<view class="u-p-20">
			<view  class="u-m-b-20 bg_FFFFFF u-p-20 u-font-28 brb_F4F4F4" v-for="(item,index) in list" :key="index">
				<view class="u-flex">
					<view class="">
						<u-image width="50rpx" height="50rpx" :src="item.avatar" mode="aspectFill"></u-image>
					</view>
					<view class="u-m-l-10">
						{{item.name}}
					</view>
				</view>
				<view class="u-m-t-20 u-flex u-flex-wrap">
					<u-image v-for="(img,imgindex) in item.img"  :key="imgindex" class="u-m-r-20" width="150rpx" height="150rpx" :src="img" mode="aspectFill"></u-image>
				</view>
				<view class="u-m-t-10 u-font-26 cl_999">
					{{item.detail}}
				</view>
			</view>
		</view>

		<!-- 加载更多 -->
		<u-loadmore :status="status" icon-type="circle" margin-bottom="20" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				params:{
					goods_id:'',
					page:1,
					page_size:20
				},
				status: 'loadmore',
				list: [],
			}
		},
		onLoad(opt) {
			this.params.goods_id=opt.id
			this.clear()
			this.goods_comment_list()
		},
		onShow() {			
		},
		// 下拉到底事件
		onReachBottom() {
			//避免多次触发
			if (this.status == 'loading' || this.status == 'nomore') {
				return;
			}
			this.goods_comment_list();
		},
		methods: {
			clear() {
				this.list = [];
				this.params.page = 1;
			},
			// 获取商品列表
			async goods_comment_list() {
				await this.$api.goods_comment_list(this.params, res => {
					if (res.data.code == 1) {
						if (res.data.data.data.length < 20) {
							this.status = 'nomore';
						} else {
							this.params.page = this.params.page + 1;
							this.status = 'loadmore';
						}
						this.list = this.list.concat(res.data.data.data);
						uni.stopPullDownRefresh();
					}
				})
			},
		}
	}
</script>

<style scoped>
</style>
